package com.ruoyi.teacher.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teacher.domain.TAward;
import com.ruoyi.teacher.service.ITAwardService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 获奖信息集Controller
 *
 * @author xiangzy
 * @date 2022-05-10
 */
@Api(tags = "获奖管理")
@RestController
@RequestMapping("/teacher/award")
public class TAwardController extends BaseController
{
    @Autowired
    private ITAwardService tAwardService;

    /**
     * 查询获奖信息集列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:award:list')")
    @GetMapping("/list")
    public TableDataInfo list(TAward tAward)
    {
        startPage();
        List<TAward> list = tAwardService.selectTAwardList(tAward);
        return getDataTable(list);
    }

    /**
     * 导出获奖信息集列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:award:export')")
    @Log(title = "获奖信息集", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TAward tAward)
    {
        List<TAward> list = tAwardService.selectTAwardList(tAward);
        ExcelUtil<TAward> util = new ExcelUtil<TAward>(TAward.class);
        return util.exportExcel(list, "award");
    }

    /**
     * 获取获奖信息集详细信息
     */
    @ApiOperation(value = "获取获奖信息集详细信息")
    @PreAuthorize("@ss.hasPermi('teacher:award:query')")
    @GetMapping(value = "/{recordid}")
    public AjaxResult getInfo(@PathVariable("recordid") Long recordid)
    {
        return AjaxResult.success(tAwardService.selectTAwardById(recordid));
    }

    /**
     * 新增获奖信息集
     */
    @PreAuthorize("@ss.hasPermi('teacher:award:add')")
    @Log(title = "获奖信息集", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TAward tAward)
    {
        return toAjax(tAwardService.insertTAward(tAward));
    }

    /**
     * 修改获奖信息集
     */
    @PreAuthorize("@ss.hasPermi('teacher:award:edit')")
    @Log(title = "获奖信息集", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TAward tAward)
    {
        return toAjax(tAwardService.updateTAward(tAward));
    }

    /**
     * 删除获奖信息集
     */
    @PreAuthorize("@ss.hasPermi('teacher:award:remove')")
    @Log(title = "获奖信息集", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordids}")
    public AjaxResult remove(@PathVariable Long[] recordids)
    {
        return toAjax(tAwardService.deleteTAwardByIds(recordids));
    }
}
